﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.ComponentModel;

    [ScriptType("SP.FolderCollection", ServerTypeId="{b6b425aa-9e17-4205-a4aa-b82c2c3f884d}")]
    public class FolderCollection : ClientObjectCollection<Folder>
    {
        [EditorBrowsable(EditorBrowsableState.Never)]
        public FolderCollection(ClientRuntimeContext Context, ObjectPath ObjectPath) : base(Context, ObjectPath)
        {
        }

        [Remote]
        public Folder Add(string strUrl)
        {
            Folder folder = new Folder(base.Context, new ObjectPathMethod(base.Context, base.Path, "Add", new object[] { strUrl }));
            folder.Path.SetPendingReplace();
            ObjectIdentityQuery query = new ObjectIdentityQuery(folder.Path);
            base.Context.AddQueryIdAndResultObject(query.Id, folder);
            base.Context.AddQuery(query);
            base.AddChild(folder);
            return folder;
        }

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = base.InitOnePropertyFromJson(peekedName, reader);
            if (flag)
            {
                return flag;
            }
            return flag;
        }
    }
}

